<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:form>
            <h:panelGrid columns="2" id="spec">     
                <p:panel header="Speciality">       
                    <h:panelGrid columns="1">
                        <p:selectOneListbox converter="specilityCon" id="acSpeciality" value="#{serviceSessionLeaveController.speciality}" style="height: 300px; width: 300px; padding: 2px; margin: auto;" >
                            <f:selectItems value="#{doctorSpecialityController.items}" var="s" itemLabel="#{s.name}" itemValue="#{s}" />
                            <p:ajax  event="change" process="@this" update="tbl scStaff"  /> 
                        </p:selectOneListbox>

                    </h:panelGrid>
                </p:panel>

                <p:panel header="Consultant">       
                    <h:panelGrid columns="1">
                        <p:selectOneListbox converter="stfcon" id="scStaff" value="#{serviceSessionLeaveController.currentStaff}" style="height: 300px; width: 300px; padding: 2px; margin: auto;" >
                            <f:selectItems value="#{serviceSessionLeaveController.consultants}" var="mys" itemLabel="#{mys.person.nameWithTitle}" itemValue="#{mys}" />
                            <p:ajax  event="change" process="@this" update="tbl"  /> 
                        </p:selectOneListbox>
                    </h:panelGrid>
                </p:panel>

                <p:dataTable id="tbl" value="#{serviceSessionLeaveController.serviceSessionLeaves}" var="d" rowStyleClass="#{d.retired ? 'crossLine':''}" >
                    <p:column>
                        <h:outputLabel value="#{d.sessionDate}">
                            <f:convertDateTime parent="YYYY MM dd" />
                        </h:outputLabel>
                    </p:column>
                    <p:column>
                        <h:outputLabel value="#{d.creater.webUserPerson.name}"/>
                    </p:column>
                    <p:column>
                        <p:commandButton value="Remove" 
                                         ajax="false" action="#{serviceSessionLeaveController.remove(d)}" 
                                         onclick="onSubmitButton();" disabled="#{d.retired eq true}"
                                         >
                            <!--<f:setPropertyActionListener value="#{d}" target="#{serviceSessionLeaveController.current}"/>-->
                        </p:commandButton>
                    </p:column>
                    
                </p:dataTable>


                <p:calendar id="calS" mode="inline" value="#{serviceSessionLeaveController.current.sessionDate}" pattern="dd MMMM yyyy" >
                    <f:ajax event="dateSelect" execute="@this"  />
                </p:calendar>
                <p:outputLabel/>
                <p:commandButton ajax="false" value="Add" action="#{serviceSessionLeaveController.removeLeave}" onclick="onSubmitButton();"/>
            </h:panelGrid>

        </h:form>

    </ui:define>


</ui:composition>
